{% extends "base.html" %}
{% load i18n %}
<body>
{% block detail %}

    <div class="main">
        <div class="ucWrap">
            <div class="ucSide">
                <h2>{% trans 'Accounts' %}</h2>
                <ul>
                    <li><a href="/my/home/">&gt; {% trans 'Browsed Cases' %}</a></li>
                    <li><a href="/my/favor/">&gt; {% trans 'Saved Cases' %}</a></li>
                    <li><a href="/my/case/">&gt; {% trans 'My Cases' %}</a></li>
                    <li><a href="/my/setting/">&gt; {% trans 'Account' %}</a></li>
                    <li class="cur"><a href="/my/password/change/">&gt; {% trans 'Change password' %}</a></li>
                </ul>
            </div>
            <div class="ucMain">
                <h2><span><b>{% trans 'Change password' %}</b></span></h2>

                <div id="validate" class="worn">
                    {% if message %}
                        {{ message }}
                    {% endif %}
                </div>
                <form class="nice" method="POST" id="changePasswordForm" action="/my/password/change/">{% csrf_token %}
                    <dl class="dl_txt clearfix">
                        <dt>{% trans 'Old password' %}：</dt>
                        <dd><input name="originalPassword" id="originalPassword" type="password" class="text"/></dd>
                    </dl>
                    <dl class="dl_txt clearfix">
                        <dt>{% trans 'New Password' %}：</dt>
                        <dd><input name="password" id="password" type="password" class="text"/></dd>
                    </dl>
                    <dl class="dl_txt clearfix">
                        <dt>{% trans 'New Password confirm' %}：</dt>
                        <dd><input name="passwordConfirm" id="passwordConfirm" type="password" class="text"/></dd>
                    </dl>
                    <div class="dl_btn"><input type="button" onclick="check()" value="{% trans 'Update' %}"/></div>
                </form>


            </div>


        </div>
    </div>

{% endblock %}
{% block js %}
    <script>
        function check() {
            if ($("#originalPassword").val() == '') {
                $("#validate").empty();
                $("#validate").html("原密码为必需项!");
                return false;
            }
            if ($("#password").val() == '') {
                $("#validate").empty();
                $("#validate").html("新密码为必需项!");
                return false;
            }
            if ($("#passwordConfirm").val() == '') {
                $("#validate").empty();
                $("#validate").html("新密码确认为必需项!");
                return false;
            }
            if ($("#password").val() != $("#passwordConfirm").val()) {
                $("#validate").empty();
                $("#validate").html("新密码及新密码确认必须相同!");
                return false;
            }
            $("#changePasswordForm").submit();
        }
    </script>
{% endblock %}
</body>
</html>